import { MyVue } from 'src/wl/my_vue';
import Vue from 'vue';
import { Component, Emit, Prop, Provide, Watch } from 'vue-property-decorator'
import { WebManageConst } from "src/consts/web_manage_const";
import { PopupName } from "src/consts/popup_const";
@Component({})
export default class webMSetPanel extends MyVue {
    name: string = 'webMSetPanel';
    formData: any;
    footerFlag: boolean = true;
    selection: any[]
    titles: String[]
    changeFlag: Boolean

    beforeCreate(): void {
    }

    initData(that: webMSetPanel): void {
        that.formData = WLStore().state.webMSet;
        that.selection = WLStore().state.webMSet.selection
        that.titles = ['账号列表', '授权账号']
        that.changeFlag = false
    }

    mounted(): void {
    }

    editAcc(): void {
        if (this.changeFlag) {
            var sendData: any = {}
            sendData.website_id = WLStore().state.webMSet.website_id

            var accArr: any = []
            for (let i = 0; i < this.selection.length; i++) {
                accArr[i] = {}
                accArr[i].id = this.selection[i].id
            }
            sendData.accounts = accArr
            WLDispatch(WebManageConst.DispatchWebMSetEdit, sendData)
        } else {
            WLLib.panel(PopupName.WebM_Set_Panel).close();
        }
    }

    change(val: any): void {
        this.selection = val
        this.changeFlag = true
    }
}